home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et-2_2.lha / et2.2 / src / Command.h < prev    next >
C/C++ Source or Header  |  1990-11-28  |  2KB  |  81 lines

  1. #ifndef Command_First
  2. #ifdef __GNUG__
  3. #pragma once
  4. #endif
  5. #define Command_First
  6.  
  7. #include "Object.h"
  8. #include "Point.h"
  9.  
  10. typedef enum {
  11.     eTrackPress,
  12.     eTrackMove,
  13.     eTrackRelease,
  14.     eTrackIdle,
  15.     eTrackExit
  16. } TrackPhase;
  17.  
  18. typedef enum {
  19.     eCmdCanUndo      = BIT(eObjLast+1),
  20.     eCmdCausesChange = BIT(eObjLast+2),
  21.     eCmdDone         = BIT(eObjLast+3),
  22.     eCmdMoveEvents   = BIT(eObjLast+4),
  23.     eCmdIdleEvents   = BIT(eObjLast+5),
  24.     eCmdFullScreen   = BIT(eObjLast+6),
  25.     eCmdDoDelete     = BIT(eObjLast+7),
  26.     eCmdNoReplFeedback= BIT(eObjLast+8),
  27.     eCmdDefault      = eCmdCanUndo | eCmdCausesChange | eCmdDoDelete,
  28.     eCmdLast         = eObjLast + 8
  29. } CommandFlags;
  30.  
  31. class Command: public Object {
  32.     int CmdNumber;
  33.     char *CmdName;
  34.  
  35. public:
  36.     MetaDef(Command);
  37.  
  38.     Command(int= 0, char *CmdName= 0, CommandFlags cf= eCmdDefault);
  39.     Command(char *CmdName, CommandFlags cf= eCmdDefault);
  40.     ~Command();
  41.  
  42.     void SetName(char *name)
  43.     { CmdName= name; }
  44.     char *GetName()
  45.     { return CmdName; }
  46.     char *GetUndoName();
  47.     void SetId(int cmd)
  48.     { CmdNumber= cmd; }
  49.     int GetId()
  50.     { return CmdNumber; }
  51.     
  52.     void Finish(Command *newcmd);
  53.     int Perform();
  54.     int Undo();
  55.     int Do();
  56.  
  57. protected:
  58.     virtual void Commit();
  59.     virtual void UndoIt();
  60.     virtual void DoIt();
  61.     virtual void RedoIt();
  62.     virtual void Done(Command *newCommand);
  63.  
  64. friend class Clipper;
  65.     virtual void TrackConstrain(Point anchorPoint, Point previousPoint, 
  66.                                 Point *nextPoint);
  67.     virtual void TrackFeedback(Point anchorPoint, Point previousPoint,
  68.         bool turnItOn);
  69.  
  70.     virtual Command *TrackMouse(TrackPhase aTrackPhase, Point anchorPoint,
  71.         Point previousPoint, Point nextPoint);
  72.  
  73.     void InspectorId(char *buf, int sz);
  74. };
  75.  
  76. extern Command *gNoChanges;
  77. extern Command *gResetUndo;
  78.  
  79. #endif Command_First
  80.  
  81.